diff options
| author | real-zephex <[email protected]> | 2024-03-17 09:24:57 +0530 |
|---|---|---|
| committer | real-zephex <[email protected]> | 2024-03-17 09:24:57 +0530 |
| commit | 39064fc306d380f8524c8b4062e3ea7fc5b16213 (patch) | |
| tree | 975113dfdb1e010b8ef6ace632c5126f60b95833 /src/app/video/[animeId] | |
| parent | Update README.md (diff) | |
| download | dramalama-39064fc306d380f8524c8b4062e3ea7fc5b16213.tar.xz dramalama-39064fc306d380f8524c8b4062e3ea7fc5b16213.zip | |
The anime section is fully server rendered!
Diffstat (limited to 'src/app/video/[animeId]')
| -rw-r--r-- | src/app/video/[animeId]/page.js | 88 |
1 files changed, 38 insertions, 50 deletions
diff --git a/src/app/video/[animeId]/page.js b/src/app/video/[animeId]/page.js index 4cd74ce..e8ec670 100644 --- a/src/app/video/[animeId]/page.js +++ b/src/app/video/[animeId]/page.js @@ -1,61 +1,49 @@ -"use client"; - +import { MediaPlayer, MediaProvider } from "@vidstack/react"; +import "@vidstack/react/player/styles/base.css"; +import "@vidstack/react/player/styles/plyr/theme.css"; +import { + PlyrLayout, + plyrLayoutIcons, +} from "@vidstack/react/player/layouts/plyr"; import "../video.css"; -import React, { useState, useEffect } from "react"; -import ReactPlayer from "react-player"; -export default function Video({ params }) { +export default async function Video({ params }) { const id = params.animeId; - const [videoLink, setVideoLink] = useState(null); - const [loading, setLoading] = useState(true); - const [epi, setEpi] = useState(""); - - useEffect(() => { - fetch("https://anime-sensei-api.vercel.app/anime/gogoanime/watch/" + id) - .then((res) => res.json()) - .then((data) => { - const words = id.split("-"); - const last_two = words.slice(-2).join(" "); - const remainingWords = words.slice(0, -2).join(" "); - setEpi([last_two, remainingWords]); - setVideoLink(data.sources[3].url); - setLoading(false); - }) - .catch((error) => { - console.log("Some error occured", error); - setLoading(false); - }); - }, [id]); + const words = id.split("-"); + const last_two = words.slice(-2).join(" "); + const remainingWords = words.slice(0, -2).join(" "); + const data = await getVideoLink(id); + const link = data.sources[3].url; return ( <div> - {loading && ( - <p - style={{ - color: "white", - fontFamily: "Lato", - fontSize: "20px", - textAlign: "center", - }} - > - Loading... + <div className="video2"> + <p> + {last_two} - {remainingWords} </p> - )} - {videoLink && ( - <div className="video2"> - <p> - {epi[0]} - {epi[1]} - </p> - <ReactPlayer - className="react-player" - url={videoLink} - controls - autoplay - width="95%" - height="95%" + <MediaPlayer + title="Test Player" + src={link} + className="testPlayer" + playsInline + aspectRatio="16/9" + load="eager" + > + <MediaProvider /> + <PlyrLayout + thumbnails="https://image.mux.com/VZtzUzGRv02OhRnZCxcNg49OilvolTqdnFLEqBsTwaxU/storyboard.vtt" + icons={plyrLayoutIcons} /> - </div> - )} + </MediaPlayer> + </div> </div> ); } + +async function getVideoLink(id) { + const res = await fetch( + "https://anime-sensei-api.vercel.app/anime/gogoanime/watch/" + id + ); + const data = res.json(); + return data; +} |